package hanjia;

import java.util.ArrayList;
import java.util.List;

/**
 * Description:
 * Author:    Dane
 * CreateTime:2025/2/15-下午12:45
 * Since  :   1.0
 * Version:   1.0
 */
public class LeetCode78 {

    public List<List<Integer>> subsets(int[] nums) {

        ArrayList<Integer> result = new ArrayList<>();
        List<List<Integer>> results = new ArrayList<>();

        int start = 0;

        backtracking(start, nums, result, results);
        return results;


    }

    private void backtracking(int start, int[] nums, ArrayList<Integer> result, List<List<Integer>> results) {

        results.add(new ArrayList<>(result));
        if (start >= nums.length) {
            return;
        }


        for (int i = start; i < nums.length; i++) {

            result.add(nums[i]);

            backtracking(i + 1, nums, result, results);
            result.remove(result.size() - 1);

        }

    }

    public static void main(String[] args) {
        int nums[] = {1, 2, 3};
        LeetCode78 leetCode78 = new LeetCode78();
        leetCode78.subsets(nums);
    }

}
